package com.android.jingweiapp.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.facebook.drawee.view.SimpleDraweeView;

import java.util.ArrayList;

public class ImageAdapter extends PagerAdapter {

    private final ArrayList<SimpleDraweeView> draweeViews;

    public ImageAdapter(ArrayList<SimpleDraweeView> draweeViews) {
        this.draweeViews = draweeViews;
    }

    @Override
    public int getCount() {
        //设置成最大，使用户看不到边界
        return draweeViews.size();
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1;
    }

    @Override
    public void destroyItem(ViewGroup container, int position,
                            Object object) {
        //Warning：不要在这里调用removeView
        container.removeView(draweeViews.get(position));
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(draweeViews.get(position));
        return draweeViews.get(position);
    }


}